<template>
  <div class="wrapper">
    <el-table
      v-loading="listLoading"
      :data="locationList"
      border
      fit
      highlight-current-row
      style="width: 100%"
    >
      <el-table-column align="center" label="PLC-ID" width="80">
        <template slot-scope="scope">
          <span>{{ scope.row.plcid }}</span>
        </template>
      </el-table-column>

      <el-table-column width="120px" align="center" label="DB块">
        <template slot-scope="scope">
          <span>{{ scope.row.dbname }}</span>
        </template>
      </el-table-column>

      <el-table-column width="120px" align="center" label="地址">
        <template slot-scope="scope">
          <span>{{ scope.row.saddr }}</span>
        </template>
      </el-table-column>

      <el-table-column align="center" label="数据类型">
        <template slot-scope="scope">
          <span>{{ scope.row.stype }}</span>
        </template>
      </el-table-column>

      <el-table-column align="center" label="备注">
        <template slot-scope="scope">
          <span>{{ scope.row.remark }}</span>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
import api from '@/utils/api'

export default {
  name: 'LocationInfo',
  data() {
    return {
      locationList: [],
      listLoading: true
    }
  },
  created() {
    this.fetchData()
  },
  methods: {
    fetchData(positionNo) {
      this.listLoading = true
      api({
        url: '/location/index',
        method: 'get',
        params: { positionNo }
      }).then(r => {
        this.locationList = r.data
        this.listLoading = false
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.wrapper {
  margin: 10px auto;
  width: 700px;
}
</style>
